package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysActcode;
import com.ruoyi.system.service.ISysActcodeService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.base.AjaxResult;

/**
 * 微信活动链接编码 信息操作处理
 * 
 * @author lzy
 * @date 2019-02-20
 */
@Controller
@RequestMapping("/system/sysActcode")
public class SysActcodeController extends BaseController
{
    private String prefix = "system/sysActcode";
	
	@Autowired
	private ISysActcodeService sysActcodeService;
	
	@RequiresPermissions("system:sysActcode:view")
	@GetMapping()
	public String sysActcode()
	{
	    return prefix + "/sysActcode";
	}
	
	/**
	 * 查询微信活动链接编码列表
	 */
	@RequiresPermissions("system:sysActcode:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(SysActcode sysActcode)
	{
		startPage();
        List<SysActcode> list = sysActcodeService.selectSysActcodeList(sysActcode);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出微信活动链接编码列表
	 */
	@RequiresPermissions("system:sysActcode:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysActcode sysActcode)
    {
    	List<SysActcode> list = sysActcodeService.selectSysActcodeList(sysActcode);
        ExcelUtil<SysActcode> util = new ExcelUtil<SysActcode>(SysActcode.class);
        return util.exportExcel(list, "sysActcode");
    }
	
	/**
	 * 新增微信活动链接编码
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存微信活动链接编码
	 */
	@RequiresPermissions("system:sysActcode:add")
	@Log(title = "微信活动链接编码", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(SysActcode sysActcode)
	{		
		return toAjax(sysActcodeService.insertSysActcode(sysActcode));
	}

	/**
	 * 修改微信活动链接编码
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		SysActcode sysActcode = sysActcodeService.selectSysActcodeById(id);
		mmap.put("sysActcode", sysActcode);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存微信活动链接编码
	 */
	@RequiresPermissions("system:sysActcode:edit")
	@Log(title = "微信活动链接编码", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(SysActcode sysActcode)
	{		
		return toAjax(sysActcodeService.updateSysActcode(sysActcode));
	}
	
	/**
	 * 删除微信活动链接编码
	 */
	@RequiresPermissions("system:sysActcode:remove")
	@Log(title = "微信活动链接编码", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(sysActcodeService.deleteSysActcodeByIds(ids));
	}
	
}
